import unittest
from typing import List
from alg import Solution 
from gen import generate_test_data 

class TestMaxProfit(unittest.TestCase):
    def setUp(self):
        self.solution = Solution()

    def test_maxProfit(self):
        # 使用固定测试数据
        self.assertEqual(self.solution.maxProfit([1, 2, 3, 0, 2]), 3)
        self.assertEqual(self.solution.maxProfit([1, 2, 3, 4, 5]), 4)
        self.assertEqual(self.solution.maxProfit([7, 1, 5, 3, 6, 4]), 7)
        self.assertEqual(self.solution.maxProfit([7, 6, 4, 3, 1]), 0)
        self.assertEqual(self.solution.maxProfit([1]), 0)
        self.assertEqual(self.solution.maxProfit([1, 1, 1, 1]), 0)

        # 使用生成的测试数据
        random_test_data = generate_test_data(10, 1, 100)  # 生成长度为10的随机数据
        print(f"随机生成的测试数据: {random_test_data}")
        result = self.solution.maxProfit(random_test_data)
        print(f"随机测试数据的结果: {result}")

if __name__ == '__main__':
    unittest.main()